from datetime import datetime
from typing import Optional, Literal

from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel

from module_admin.annotation.pydantic_annotation import as_query, as_form


class ThesaurusModel(BaseModel):
    """
    专业词库表对应pydantic模型
    """

    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    thesaurus_id: Optional[int] = Field(default=None, description='词库主键')
    thesaurus_name: Optional[str] = Field(default=None, description='词库名称')
    thesaurus_type: Optional[str] = Field(default=None, description='词库类型')
    status: Optional[Literal['0', '1']] = Field(default=None, description='状态（0正常 1停用）')
    create_by: Optional[str] = Field(default=None, description='创建者')
    create_time: Optional[datetime] = Field(default=None, description='创建时间')
    update_by: Optional[str] = Field(default=None, description='更新者')
    update_time: Optional[datetime] = Field(default=None, description='更新时间')
    remark: Optional[str] = Field(default=None, description='备注')


class ThesaurusDataModel(BaseModel):
    """
    专业词库详细信息表对应pydantic模型
    """

    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    data_id: Optional[int] = Field(default=None, description='数据主键')
    data_name: Optional[str] = Field(default=None, description='数据名称')
    thesaurus_type: Optional[str] = Field(default=None, description='词库类型')
    data_sort: Optional[int] = Field(default=None, description='数据排序')
    status: Optional[Literal['0', '1']] = Field(default=None, description='状态（0正常 1停用）')
    create_by: Optional[str] = Field(default=None, description='创建者')
    create_time: Optional[datetime] = Field(default=None, description='创建时间')
    update_by: Optional[str] = Field(default=None, description='更新者')
    update_time: Optional[datetime] = Field(default=None, description='更新时间')
    remark: Optional[str] = Field(default=None, description='备注')


class ThesaurusQueryModel(ThesaurusModel):
    """
    词库管理分页查询模型
    """

    begin_time: Optional[str] = Field(default=None, description='开始时间')
    end_time: Optional[str] = Field(default=None, description='结束时间')


class ThesaurusDataQueryModel(ThesaurusDataModel):
    """
    词库管理分页查询模型
    """

    begin_time: Optional[str] = Field(default=None, description='开始时间')
    end_time: Optional[str] = Field(default=None, description='结束时间')


@as_query
@as_form
class ThesaurusPageQueryModel(ThesaurusQueryModel):
    """
    词库管理分页查询模型
    """

    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')


@as_query
@as_form
class ThesaurusDataPageQueryModel(ThesaurusDataQueryModel):
    """
    词库管理分页查询模型
    """

    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')


class DeleteThesaurusModel(BaseModel):
    """
    删除字典类型模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    thesaurus_ids: str = Field(description='需要删除的字典主键')


class DeleteThesaurusDataModel(BaseModel):
    """
    删除字典类型模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    data_ids: str = Field(description='需要删除的字典主键')
